package com.bnq.logc.logger

import com.bnq.logc.LogcDispatcher
import com.bnq.logc.action.WriteAction

class WriteLogger(val dispatcher: LogcDispatcher) : Logger {

    override fun isEnabled(): Boolean = true

    override fun log(level: Int, tag: String, log: String) {
        val action = WriteAction(
            level,
            tag,
            log,
            System.currentTimeMillis(),
            "${Thread.currentThread().name}:${Thread.currentThread().id}",
            false
        )
        if(action.isValid()){
            dispatcher.dispatchAction(action)
        }
        if(action.isDangerousEvent()){
            dispatcher.dispatchUpload(action)
        }
    }
}